﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace nvwamakeperson
{
    internal class MakePerson
    {
        public static Person CreatePerson(string type)
        {
            switch (type)
            {
                case "M":
                    return new Man();
                case "W":
                    return new Woman();
                case "R":
                    return new RobotAdapter(new Robot()); // 使用适配器模式将Robot对象适配成Person类型
                default:
                    return null;
            }
        }

        private class RobotAdapter : Person
        {
            private Robot _robot;

            public RobotAdapter(Robot robot)
            {
                _robot = robot;
            }

            public override string MyType()
            {
                return _robot.MyType();
            }
        }
    }
}
